// config/api-endpoints.js - API端点配置工具

// 可用的API端点配置
const API_ENDPOINTS = {
  // 配置1: 标准RESTful API
  RESTFUL: {
    RECHARGE_LIST: '/recharge/list',
    RECHARGE_DETAIL: '/recharge/detail',
    RECHARGE_CREATE: '/recharge/create',
    RECHARGE_UPDATE: '/recharge/update',
    RECHARGE_DELETE: '/recharge/delete'
  },

  // 配置2: 带API前缀
  API_PREFIX: {
    RECHARGE_LIST: '/api/recharge/list',
    RECHARGE_DETAIL: '/api/recharge/detail',
    RECHARGE_CREATE: '/api/recharge/create',
    RECHARGE_UPDATE: '/api/recharge/update',
    RECHARGE_DELETE: '/api/recharge/delete'
  },

  // 配置3: 门诊相关
  OUTPATIENT: {
    RECHARGE_LIST: '/outpatient/recharge/list',
    RECHARGE_DETAIL: '/outpatient/recharge/detail',
    RECHARGE_CREATE: '/outpatient/recharge/create',
    RECHARGE_UPDATE: '/outpatient/recharge/update',
    RECHARGE_DELETE: '/outpatient/recharge/delete'
  },

  // 配置4: 医疗相关
  MEDICAL: {
    RECHARGE_LIST: '/medical/recharge/list',
    RECHARGE_DETAIL: '/medical/recharge/detail',
    RECHARGE_CREATE: '/medical/recharge/create',
    RECHARGE_UPDATE: '/medical/recharge/update',
    RECHARGE_DELETE: '/medical/recharge/delete'
  }
}

// 当前使用的配置 (可以在这里快速切换)
const CURRENT_CONFIG = 'RESTFUL' // 可选: 'RESTFUL', 'API_PREFIX', 'OUTPATIENT', 'MEDICAL'

// 获取当前配置的端点
const getCurrentEndpoints = () => {
  return API_ENDPOINTS[CURRENT_CONFIG] || API_ENDPOINTS.RESTFUL
}

// 构建完整的API URL
const buildApiUrl = (endpointKey, baseUrl = 'http://localhost:8084') => {
  const endpoints = getCurrentEndpoints()
  const endpoint = endpoints[endpointKey]
  
  if (!endpoint) {
    console.error(`未找到端点: ${endpointKey}`)
    return ''
  }
  
  return `${baseUrl}${endpoint}`
}

// 导出配置
module.exports = {
  API_ENDPOINTS,
  CURRENT_CONFIG,
  getCurrentEndpoints,
  buildApiUrl,
  
  // 便捷方法
  getRechargeListUrl: (baseUrl) => buildApiUrl('RECHARGE_LIST', baseUrl),
  getRechargeDetailUrl: (baseUrl) => buildApiUrl('RECHARGE_DETAIL', baseUrl),
  getRechargeCreateUrl: (baseUrl) => buildApiUrl('RECHARGE_CREATE', baseUrl),
  getRechargeUpdateUrl: (baseUrl) => buildApiUrl('RECHARGE_UPDATE', baseUrl),
  getRechargeDeleteUrl: (baseUrl) => buildApiUrl('RECHARGE_DELETE', baseUrl)
} 